package cn.ld.module.infra.dal.mapper.codegen;

import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.infra.dal.entity.codegen.CodegenColumnEntity;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CodegenColumnMapper extends BaseMapperX<CodegenColumnEntity> {

    default List<CodegenColumnEntity> selectListByTableId(Long tableId) {
        return selectList(new LambdaQueryWrapperX<CodegenColumnEntity>()
                .eq(CodegenColumnEntity::getTableId, tableId)
                .orderByAsc(CodegenColumnEntity::getOrdinalPosition));
    }

    default void deleteListByTableId(Long tableId) {
        delete(new LambdaQueryWrapperX<CodegenColumnEntity>()
                .eq(CodegenColumnEntity::getTableId, tableId));
    }

}
